{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b000342f",
   "metadata": {},
   "source": [
    "## 本周学习内容\n",
    "### 1. 课本项目直接运行\n",
    "### 2. 认识变量\n",
    "### 3. 赋值的概念\n",
    "### 4. python语言的基本数据结构：（文本、数值）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b6cf5247",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.datetime.today().minute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c09d9710",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This munute semms a little odd.\n"
     ]
    }
   ],
   "source": [
    "# 1. 课本项目直接运行\n",
    "# 先找到模块，然后从模块中调用一个方法： from 模块名字 import 模块方法\n",
    "from datetime import datetime\n",
    "\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "right_this_minute = datetime.today().minute # 一直在变化的当前时间的 分钟数\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This munute semms a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95b010b7",
   "metadata": {},
   "source": [
    "> 1. 变量的概念\n",
    "* **变量**用于存储要在计算机程序中引用和操作的信息。它们还提供了一种用描述性名称标记数据的方法，以便读者和我们自己能够更清楚地理解我们的程序。将变量看作包含信息的容器是有帮助的。它们的唯一目的是在内存中标记和存储数据。然后可以在整个程序中使用这些数据。\n",
    "> 2. 变量名称的规范\n",
    ">> 1. 变量名称只可以用数字、字母和下滑线来定义名称\n",
    ">> 2. 数字不可以作为变量名的第一个字符\n",
    ">> 3. 内部（开发团队）以及使用过的名称不可以作为变量名,例如：\n",
    "['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']\n",
    ">> 4. 如果你实在想定义一个已经被用过的名字，可以在已有名字后面加上下划线和自己的名字，如global_Wenxuan"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4ef1e8cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jack\n"
     ]
    }
   ],
   "source": [
    "# 变量实践\n",
    "name = \"Jack\" #赋值\n",
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "d9340f44",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinWenxuan\n"
     ]
    }
   ],
   "source": [
    "# 变量实践2\n",
    "first_name = \"Lin\"\n",
    "last_name = \"Wenxuan\"\n",
    "name = first_name+''+last_name\n",
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "7c934bcf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Alex Alex\n",
      "Lin,Alex Alex\n"
     ]
    }
   ],
   "source": [
    "# 变量实践3\n",
    "name_01 = \"Alex\"\n",
    "name_02 = name_01\n",
    "\n",
    "print(name_01,name_02)\n",
    "\n",
    "name_01 = \"Lin,Alex\"\n",
    "\n",
    "print(name_01,name_02)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37ada758",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 以上结果原因：\n",
    "# 1. python是一门解释性语言，是一行一行执行的，没有特定的要求，是不会重复运行上一行代码的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b3610ef",
   "metadata": {},
   "source": [
    "> 1. 阅读字符串概念\n",
    ">> 1. [字符串](https://docs.python.org/3/tutorial/introduction.html#strings)\n",
    ">> 2. [字符串方法](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)\n",
    "> 2. 阅读数值概念\n",
    ">> 1. [数值](https://docs.python.org/3/tutorial/introduction.html#numbers)\n",
    ">> 2. [数值方法](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c33b9e89",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-22-ad4652f0f08e>, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-22-ad4652f0f08e>\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m    phrase = 'doesn't'\u001b[0m\n\u001b[1;37m                    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# invalid syntax 语法错误\n",
    "phrase = 'doesn't'\n",
    "phrase"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "26ba1830",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"doesn't\" # 解决方法1\n",
    "'doesn\\'t' # 解决方法2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "563a5764",
   "metadata": {},
   "source": [
    "# 字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "344d2f92",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串 三引号 \"\"\" \"\"\" 或者 ''' '''\n",
    "# 三引号 可以存储较为复杂的文本数据（例如可以存 其他语言的 数据）\n",
    "# 字符串可以用+运算符连接（粘合在一起），并用 重复"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "03bf9cca",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinWenxuan\n"
     ]
    }
   ],
   "source": [
    "# 字符串的拼接\n",
    "print(\"Lin\"+\"\"+\"Wenxuan\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d47c558f",
   "metadata": {},
   "source": [
    "* 字符串可以被索引（下标）\n",
    "> 尝试写下course_name[0] course_name[1] course_name[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "fe9f9a2a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'interactive-media-production'"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name = \"interactive-media-production\"\n",
    "course_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "88604a15",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'i'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[0]\n",
    "# 尝试取出 media\n",
    "# 0就是第一个字母"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "c38af78b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'media'"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[12]+course_name[13]+course_name[14]+course_name[15]+course_name[16]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "9984a724",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'media'"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[12:17]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "b7577ab4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'damn'"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[14]+course_name[5]+course_name[12]+course_name[1]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a2c759b",
   "metadata": {},
   "source": [
    "### （恶趣味了属于是）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "b169c071",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'cti'"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[-5:-2]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "004f5d58",
   "metadata": {},
   "source": [
    "* 切片(slice)的性质\n",
    "> 1. [值1:值2]值1<值2\n",
    "> 2. [值1:值2]值2是取不到的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb6abc0f",
   "metadata": {},
   "source": [
    "# 数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "ef0a4313",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "300"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "100+200"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "48e64f6c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "print(type(2021))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "562ce045",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "print(type(3.14159265358979323846))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "12182433",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "print(type(3+2j))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10198c05",
   "metadata": {},
   "source": [
    "# 数值和字符串一定要分清！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "a50f0cf7",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = \"50\" #字符串\n",
    "b = 40 #数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "003deb7b",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "can only concatenate str (not \"int\") to str",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-65-bd58363a63fc>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str"
     ]
    }
   ],
   "source": [
    "a + b"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b601d3ef",
   "metadata": {},
   "source": [
    "### 课后作业（打印当天的课程表）\n",
    "* 1. 使用time模块获取当天是周几\n",
    "* 2. 获取到周几之后，print(\"\")可以尝试打印的好看一点\n",
    "> 一定要用到if条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "730788d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "weekly\n",
    "if weekly == 1:\n",
    "    print(周一的课程)\n",
    "elif weekly == 2:\n",
    "    print(周二的课程)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
